<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="test1">点击1</div>
    <div id="test2">点击2</div>
    <div id="test3" onclick="fn()">点击3</div>
    <script type="text/javascript">
      const test1 = document.getElementById("test1");
      test1.onclick = function () {
        console.log("点击了 test1.onclick");
      };
      const test2 = document.getElementById("test2");
      test2.addEventListener("click", function () {
        console.log("点击了  test2.addEventListener");
      });
      const fn = () => {
        console.log("点击了fn   onClick='fn()' ");
      };
      //在react里三种方式都可以用 但是最推荐是 第三种 ：  <div id="test3" onClick="fn()">点击3</div>
    </script>
  </body>
</html>
